# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=dune
pkgver=2.6.0
pkgrel=0
pkgdesc="A composable build system for OCaml (formerly Jbuilder)"
url="https://github.com/ocaml/dune"
arch="all !x86 !armhf !armv7 !mips !mips64"  # limited by ocaml abuild
license="Apache-2.0"
checkdepends="bash"
makedepends="ocaml ocaml-compiler-libs ocaml-findlib-dev"
provides="jbuilder=$pkgver-r$pkgrel"
subpackages="$pkgname-doc $pkgname-emacs::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml/dune/archive/$pkgver.tar.gz"
options="!check"  # FIXME requires ocaml-menhir

build() {
	make release
}

check() {
	make test
}

package() {
	DESTDIR="$pkgdir" make install

	# Fix docs location
	mv "$pkgdir"/usr/doc "$pkgdir"/usr/man "$pkgdir"/usr/share
}

emacs() {
	depends="$pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel emacs"
	pkgdesc="Emacs plugins for $pkgname"

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/emacs/ "$subpkgdir"/usr/share/emacs/
}

sha512sums="2940b432504331dccbfbd61bf32f4960286efab34de65df1c335226ab3d48b2225569774674b09ef0846bc3a691eea0eeb1d688855e37be7b2b69adf69cb2a29  dune-2.6.0.tar.gz"
